import {RvaUtils} from "@/api/rva/util";
import {handleRvaButtonClick} from "@/api/rva/crud";
import request from '@/utils/request'
export default {
  props: ['prop'],
  components: {
    'rva-form': () => import('@/components/rva/form'),
    'rva-crud': () => import('@/components/rva/crud'),
    'rva-tcrud': () => import('@/components/rva/tcrud')
  },
  created() {
  },
  data() {
    return {
      devMode: RvaUtils.isDevMode(),
      openConfig: false,
      openClone: false,
    }
  },
  methods: {
    executeCommand (command) {
      console.log ('command', command);
      if (RvaUtils.isObject(command)) {
        eval('this.' + command.name + '(command)');
        return;
      }
      console.log ('this.' + command + '()');
      eval('this.' + command + '()');
    },
    configProperty() {
      this.openConfig = true;
    },
    cloneProperty() {
      this.openClone = true;
    },
    deleteProperty() {
      if (confirm('确定要删除吗？')) {
        request({
          url: '/rva/metaapp/viewproperty/' + this.prop.id + '/delete',
          method: 'post'
        })
      }
    },
    handleFormButtonClick (data) {
      handleRvaButtonClick(this, data);
    },
  }
};
